package com.ibiaoke.goods.dao;

import com.ibiaoke.common.base.BaseDao;
import com.ibiaoke.goods.entity.ShopPrice;
import com.ibiaoke.goods.entity.ShopPriceExample;
import com.ibiaoke.goods.mapper.ShopPriceMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class ShopPriceDao extends BaseDao<ShopPrice,ShopPriceExample,Integer,ShopPriceMapper> {

    @Autowired
    private ShopPriceMapper shopPriceMapper;

    @Override
    public ShopPriceMapper getMapper() {
        return shopPriceMapper;
    }

    public List<ShopPrice> listShopPrice(List<Integer> goodsIds, Integer shopId) {
        ShopPriceExample example = new ShopPriceExample();
        example.createCriteria().andGoodsIdIn(goodsIds).andShopIdEqualTo(shopId);
        return selectByExample(example);
    }

    public int delShopPrice(Integer goodsId) {
        ShopPriceExample example = new ShopPriceExample();
        example.createCriteria().andGoodsIdEqualTo(goodsId);
        return deleteByExample(example);
    }

    public List<ShopPrice> listShopPrice(Integer goodsId) {
        ShopPriceExample example = new ShopPriceExample();
        example.createCriteria().andGoodsIdEqualTo(goodsId);
        return shopPriceMapper.selectByExample(example);
    }
}
